﻿/*
 * Realistic Sniper and Ballistics System
 * Copyright (c) 2021, Inan Evin, Inc. All rights reserved.
 * Author: Inan Evin
 * https://www.inanevin.com/
 * 
 * Documentation: https://rsb.inanevin.com
 * Contact: inanevin@gmail.com
 * Support Discord: https://discord.gg/RCzpSAmBAb
 *
 * Feel free to ask about RSB, send feature recommendations or any other feedback!
 */

using UnityEngine;

namespace IE.RSB
{
    /// <summary>
    /// Represents a point in the travel path of the bullet. Hit events are sent with BulletPoint objects as arguments, 
    /// They contain information such as the origin & direction of the final raycast that concluded with the hit, or the hit information such as hit type,
    /// point, normal, or bullet information such as travel time or kinetic energy.
    /// Primarily used in Bullet Time to record every point bullet ray has travelled through, so we can actually interpolate a bullet object through these
    /// points in bullet time. Secondarily used in hit events, as mentioned above.
    /// 表示子弹行进路径上的一个点。命中事件以子弹点对象作为参数发送，
    ///它们包含了一些信息，例如最终光线投射的原点和方向，以及命中类型等信息；
    ///点，正常，或子弹信息，如旅行时间或动能。
    ///主要用于子弹时间记录子弹射线经过的每一个点，所以我们可以通过这些插入一个子弹对象
    ///子弹时间点。其次用于命中事件，如上所述。
    /// </summary>
    public class BulletPoint
	{
		public BulletProperties m_properties;
		public enum PointHitType { None, Normal, PenetrationIn, PenetrationOut, Ricochet};
		public PointHitType m_hitType;

		/// <summary>
		///  Origin of the ray that caused this point/hit.
		/// </summary>
		public Vector3 m_origin;

        /// <summary>
        /// End point of the ray that caused this point/hit. If hit type is not None, than this means hit point.
        /// 造成这个点/命中的射线的终点。如果命中类型不是None，则表示命中值。
        /// </summary>
        public Vector3 m_endPoint;

		/// <summary>
		/// Hit normal, only if hit type is not None.
		/// </summary>
		public Vector3 m_hitNormal;

        /// <summary>
        /// Direction of the ray that caused this point/hit.
        /// 造成这个点/命中的射线的方向。
        /// </summary>
        public Vector3 m_direction;

		/// <summary>
		/// Velocity of the bullet.
		/// </summary>
		public Vector3 m_velocity;

        /// <summary>
        /// Hit transform, only if hit type is not None.
        /// 只有当hit type不是None时，它才会转换。
        /// 击中物体的位置信息
        /// </summary>
        public Transform m_hitTransform;

        /// <summary>
        /// Kinetic energy of the bullet.
        /// 子弹的动能。
        /// </summary>
        public float m_kineticEnergy;

		/// <summary>
		/// Time passed since the bullet was fired.
		/// </summary>
		public float m_travelTime;

        /// <summary>
        /// Used internally for Bullet Time Events.
        /// 内部用于子弹时间事件。
        /// </summary>
        public bool m_isPointAfterTargetHit;
	}

}
